package com.hjm.project.ActActivityDistribution.ActActivityDistribution.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.ActActivityDistribution.ActActivityDistribution.domain.ActActivityDistribution;
import com.hjm.project.ActActivityDistribution.ActActivityDistribution.service.IActActivityDistributionService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 活动分润对象Controller
 * 
 * @author ActActivityDistribution
 * @date 2020-11-29
 */
@Controller
@RequestMapping("/ActActivityDistribution/ActActivityDistribution")
public class ActActivityDistributionController extends BaseController
{
    private String prefix = "ActActivityDistribution/ActActivityDistribution";

    @Autowired
    private IActActivityDistributionService actActivityDistributionService;

    @RequiresPermissions("ActActivityDistribution:ActActivityDistribution:view")
    @GetMapping()
    public String ActActivityDistribution()
    {
        return prefix + "/ActActivityDistribution";
    }

    /**
     * 查询活动分润对象列表
     */
    @RequiresPermissions("ActActivityDistribution:ActActivityDistribution:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ActActivityDistribution actActivityDistribution)
    {
        startPage();
        List<ActActivityDistribution> list = actActivityDistributionService.selectActActivityDistributionList(actActivityDistribution);
        return getDataTable(list);
    }

    /**
     * 导出活动分润对象列表
     */
    @RequiresPermissions("ActActivityDistribution:ActActivityDistribution:export")
    @Log(title = "活动分润对象", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ActActivityDistribution actActivityDistribution)
    {
        List<ActActivityDistribution> list = actActivityDistributionService.selectActActivityDistributionList(actActivityDistribution);
        ExcelUtil<ActActivityDistribution> util = new ExcelUtil<ActActivityDistribution>(ActActivityDistribution.class);
        return util.exportExcel(list, "ActActivityDistribution");
    }

    /**
     * 新增活动分润对象
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存活动分润对象
     */
    @RequiresPermissions("ActActivityDistribution:ActActivityDistribution:add")
    @Log(title = "活动分润对象", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ActActivityDistribution actActivityDistribution)
    {
        return toAjax(actActivityDistributionService.insertActActivityDistribution(actActivityDistribution));
    }

    /**
     * 修改活动分润对象
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ActActivityDistribution actActivityDistribution = actActivityDistributionService.selectActActivityDistributionById(id);
        mmap.put("actActivityDistribution", actActivityDistribution);
        return prefix + "/edit";
    }

    /**
     * 修改保存活动分润对象
     */
    @RequiresPermissions("ActActivityDistribution:ActActivityDistribution:edit")
    @Log(title = "活动分润对象", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ActActivityDistribution actActivityDistribution)
    {
        return toAjax(actActivityDistributionService.updateActActivityDistribution(actActivityDistribution));
    }

    /**
     * 删除活动分润对象
     */
    @RequiresPermissions("ActActivityDistribution:ActActivityDistribution:remove")
    @Log(title = "活动分润对象", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(actActivityDistributionService.deleteActActivityDistributionByIds(ids));
    }
}
